<template>
  <div>
    <h3>目前只支持Excel格式</h3>
    <input type="file" @change="inputFileChange">
    <button type="submit" @click="clicks">导入</button>
  </div>
</template>

<script>
import { ImportData } from '@/api/import'

export default {
  data () {
    return {
      files: ''
    }
  },
  mounted: function () {
  },
  methods: {
    inputFileChange (e) {
      this.files = e.target.files[0]
    },

    clicks () {
      if (this.files) {
        const fd = new FormData()
        fd.append('file', this.files)
        ImportData(fd).then(res => {
        })
      }
    }
  }
}

</script>
